/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package csse3004.GD.PC;

import csse3004.GD.DA.PollCreatorDA;
import javax.servlet.ServletException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;

/**
 *
 * @author Lewis Kelly 42007689
 */
public class addAnswerController extends SimpleFormController {

    protected final Log logger = LogFactory.getLog(getClass());
    private PollCreatorService serv = new PollCreatorDA();
    ModelAndView mnv = new ModelAndView("success");

    public ModelAndView onSubmit(Object command) throws ServletException {

        addAnswer add = new addAnswer();

        String a1 = add.getA1();
        String a2 = add.getA2();
        String a3 = add.getA3();
        String a4 = add.getA4();
        String a5 = add.getA5();
        String a6 = add.getA6();
        String a7 = add.getA7();
        String a8 = add.getA8();
        String a9 = add.getA9();
        String a10 = add.getA10();

        if (a10.equals("")) {
            logger.info("hi");
        }

        //NEED TO ADD ALL THINGS, INCLUDING GETTING STUFF
//        String success = "Your answer has been successfully submitted!!";
//        String failure = "Your answer was not successfully submitted, please try again";
//        
//        addSpecMCQ co = (addSpecMCQ) command;
//        String qrank;
//        String qdemo;
//        String qcomp;
//        String qtext = co.getQuestionText();
//        String qtemplate = "No";
//        String qtype = co.getStyle();
//        int id = co.getPollID();
//        int type = co.getqStyle();
//        if (type == 1) {
//            qrank = "No";
//            qdemo = "Yes";
//            qcomp = "No";
//            pollCreatorService.addMCQuestion(qtext, qtype, qtemplate, qrank, qdemo, qcomp, id);
//            logger.info("Demographic"+type);
//            mnv.addObject("succ", success);
//            return mnv;
//        } else if (type == 2) {
//            qrank = "No";
//            qdemo = "No";
//            qcomp = "Yes";
//            logger.info("Comparative"+type);
//            pollCreatorService.addMCQuestion(qtext, qtype, qtemplate, qrank, qdemo, qcomp, id);
//            mnv.addObject("succ", success);
//            return mnv;
//        } else if (type == 3) {
//            qrank = "Yes";
//            qdemo = "No";
//            qcomp = "No";
//            logger.info("Ranking"+type);
//            pollCreatorService.addMCQuestion(qtext, qtype, qtemplate, qrank, qdemo, qcomp, id);
//            mnv.addObject("succ", success);
//            return mnv;
//        } else {
//            mnv.addObject("fail", failure);
//            return mnv;
//        }
        return mnv;
    }
}
